
export interface IExportParamModelData {
    /**
     * 模型的唯一识别id
     */
    id: string;
    /**
     * 子模型列表
     */
    subModels: IExportParamModelData[];
    /**
     * 模型在方案中的名称
     */
    modelName: string;
    /**
     * 模型参数列表
     */
    parameters: any[];
    /**
     * 分类id
     */
    prodCatId: number;
    /**
     * 商品id
     */
    obsBrandGoodId: string;
}

export function flattenModels(paramModels: Array<IExportParamModelData>) {
    const models: Array<IExportParamModelData> = []
    const queue: Array<IExportParamModelData> = [...paramModels];
    while (queue.length) {
        const cur = queue.shift()!;
        models.push(cur);
        if (cur.subModels) {
            queue.push(...cur.subModels);
        }
    }
    return models;
};


export function uuid() {
    let array = new Uint32Array(4);
    crypto.getRandomValues(array);
    let uuid = '';
    array.forEach(function (value) {
        uuid += value.toString(16).padStart(8, '0');
    });
    return uuid;
}